var a = require("../../@babel/runtime/helpers/interopRequireDefault"),
  e = a(require("../../utils/util")),
  t = a(require("../../utils/logs")),
  o = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    items: [],
    money: '',
    show1: false, //红包领取过提示弹窗
    countPage: '',
    page: 1,
    show2: false,//领取红包弹窗
    videoShow: false, //视频弹窗
    isvideoEnd: false,
    options: 0, //0首页点击跳转 1首页弹窗领取红包跳转
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      naviType: options.naviType ? options.naviType : 0
    })
    this.lingquguo()
    this.getData()
  },
  onShow() {
    wx.hideHomeButton()
  },
  getData() {
    var e = this,
      t = o.getNetAddresss("Feilong.user_alllist");
    o._getNetWork({
      url: t,
      data: {
        uid: wx.getStorageSync("yz_uid"),
      },
      success: function (a) {
        e.setData({
          items: a.data.data.list,
          money: a.data.data.money
        })
        let arr = a.data.data.list
        e.data.items = arr.map((item) => {
          return {
            ...item,
            mobile: item.mobile.replace(/(\d{3})\d*(\d{3})/, "$1*****$2")
            //  this.setData({ tel: enStr, idCard: enStr1 })
          }
        })
        e.setData({
          items: e.data.items,
        })
        console.log('aaaaaaaaaaaa', e.data.items)
        if (a.statusCode == 200 && a.data.result == 1) {
          e.setData({
            countPage: a.data.data.list.last_page,
          })
          if (e.data.page == 1) {
            var dataList = a.data.data.list.data
          } else {
            var dataList = e.data.items
            dataList = dataList.concat(a.data.data.list.data)
          }
          e.setData({
            items: dataList,
          })
          console.log('09090', dataList)
        }
        console.log(a.data.data.list, '飞龙海')

      }
    });
  },

  closeHuanniuPop: function () {
    console.log(this.data.show1, 'activePopShow')
    this.setData({
      show1: false
    });
  },
  closeHuanniuPop2: function () {
    console.log(this.data.show2, 'activePopShow2')
    this.setData({
      show2: false
    });
  },
  showPopup() {
    this.setData({
      show1: true
    });
  },

  onClose() {
    this.setData({
      show1: false
    });
  },
  showPopup2() {
    this.setData({
      show2: true
    });
  },

  onClose2() {
    this.setData({
      show2: false
    });
  },
  checkList() {
    wx.navigateTo({
      url: '/packageG/checkList/checkList',
    })
  },
  //   领取红包弹窗走接口
  lingqu() {
    this.setData({
      show1: false
    })
  },
  //   领取红包弹窗走接口
  lingquhongbao() {
    if (!this.data.isvideoEnd) {
      wx.showToast({
        title: '视频播放完才能领取红包',
        icon: 'none'
      })
      return
    }
    var e = this,
      t = o.getNetAddresss("Feilong.hongbaoReward");
    o._getNetWork({
      url: t,
      data: {
        uid: wx.getStorageSync("yz_uid"),
      },
      success: function (a) {
        if (a.data.msg == "success") {
          e.setData({
            videoShow: false
          })
          setTimeout(() => {
            wx.showToast({
              title: '领取成功',
              icon: 'none'
            })
          }, 1000)
          e.getData()
          // wx.navigateTo({
          //     url: '/packageG/newList/newList',
          // })
        }
        console.log(a.data.msg, 'hongbao')
      }
    });
  },
  taphongbao() {
    console.log('ihoghyfyuyfgkuygkuighyufv')
    this.setData({
      show2: false,
      videoShow: true
    })

  },
  onCloseVideoPop() {
    this.setData({
      videoShow: false
    });
  },
  closeVideoPop: function () {
    this.setData({
      videoShow: false
    });
  },
  onPlayVideo: function () {
    console.log('播放了')

  },
  ended: function () {
    console.log('播放完了')
    this.setData({
      // show2: true,
      // videoShow: false,
      isvideoEnd: true
    })
  },
  //是否领取过红包
  lingquguo() {
    var e = this,
      t = o.getNetAddresss("Feilong.is_lingqu");
    o._getNetWork({
      url: t,
      data: {
        uid: wx.getStorageSync("yz_uid"),
      },
      success: function (a) {
        if (a.data.data >= 1) {
          console.log(a.data.data, '已领取')
          if (e.data.naviType == 0) {
            e.setData({
              show1: true
            })
          }

          // e.setData({
          //   show1: true,
          //   videoShow: false
          // })
        } else {
          e.setData({
            show2: true
          })
          // e.setData({
          //   videoShow: true
          // })
        }
        console.log(a.data, 'lingquguo')
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },



  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  onPullDownRefresh() {
    this.data.page = 1;
    this.getData()
  },
  onReachBottom() {
    console.log('到达底部')
    if (this.data.countPage > this.data.page) {
      this.data.page++;
      this.getData()
    } else {
      if (this.data.page != 1) {
        wx.showToast({
          title: '已加载全部',
          icon: 'none'
        })
      }
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})